package com.xbongbong.saas.factory.score;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.ErrorCodeEnum;
import com.xbongbong.pro.enums.errorcodes.ScoreErrorCodeEnum;
import com.xbongbong.saas.service.ScoreConditionService;
import com.xbongbong.saas.service.impl.ComplexScoreConditionServiceImpl;
import com.xbongbong.saas.service.impl.SingleScoreConditionServiceImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ScoreConditionFactory {

    @Resource
    private SingleScoreConditionServiceImpl singleScoreConditionService;
    @Resource
    private ComplexScoreConditionServiceImpl complexScoreConditionService;

    public ScoreConditionService getScoreConditionService(FieldTypeEnum fieldTypeEnum) throws XbbException {
        switch (fieldTypeEnum) {
            case DATETIME:
            case TEXT:
            case COMBO:
            //阶段推进器
            case STAGE_THRUSTER:
            case RADIO_GROUP:
            case TEXTAREA:
            case NUM:
            case ADDTIME:
            case UPDATETIME:
                return singleScoreConditionService;
            case CHECKBOX_GROUP:
            case COMBO_CHECK:
            case LABEL:
                return complexScoreConditionService;
            default:
                throw new XbbException(ScoreErrorCodeEnum.API_ERROR_1200010.getCode(), ScoreErrorCodeEnum.API_ERROR_1200010.getMsg());
        }
    }
}
